<template>
	<!-- 充值页面 -->
	<div class="weui-panel" style="height:100% ;background-color: #efefef;">
		<div class="weui-panel__bd " style="height: 13.25rem;background-color: white;margin: 0.8125rem;">
			<div class="weui-form" style="margin: 3px 3px;height: 100%;">
				<div class="weui-flex__item">
					<div class="weui-cell_access " style="text-align: center;">账户余额（元)</div>
					<div style="text-align: center;font-size: 1.2625rem;width: 100%;">{{memberInfo.moneySurplus}}</div>
				</div>
			</div>
		</div>
		<div style="position: absolute;bottom: 10px;width: 100%;">
			<button class="btn" @click="goBack">返回</button>
		</div>
		
		<div class="weui-grids" style="background-color: white;">
			<a class="weui-grid" v-for="(item,index) in recharges">
				<a class="weui-grid__icon">{{item.oldSale}}元</a>
				<a class="weui-grid__label">售价{{item.newSale}}元</a>
			</a>
			<a class="weui-grid" >
				<a @click="showChargeFlag = true" class="weui-grid__icon">其他金额</a>
				
			</a>
		</div>
		<button @click="showChargeFlag = true" class="weui-btn weui-btn_block weui-btn"
			style="background-color: #4fd545;margin-top: 1.25rem;">充值</button>
		<!-- 弹框填写 -->
		<div class="dialogMain" v-if="showChargeFlag">
			<div class="bodymain">
				<div class="weui-cell__hd " style="margin: 0.625rem;font-size: 1.5625rem;line-height: 1.875rem;">
					<input class="weui-input" style="text-align: center;" placeholder="请输入金额" type="number"
						v-model="rechargeMoney" />
				</div>
				<div class="weui-cell__bd" style="text-align: center; display: flex;">
					<a @click="chargeMoney"
						style="background-color: #00bd00;color: white;width: 50%;margin: 0 0.3125rem 0.3125rem 0.3125rem;"
						class="weui-btn ">充值</a>
					<a @click="showChargeFlag = !showChargeFlag"
						style="background-color: #b6b68c;color: white;width: 50%;margin: 0 0.3125rem 0.3125rem 0.3125rem;"
						class="weui-btn ">取消</a>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import apis from '@/utils/apis.js'
	import {
		getUserInfo
	} from '@/apis/wx/weixinJs.js'
	import {
		getDisCounts
	} from '@/apis/wx/recharge.js'
	import constant from '@/utils/constant'
	export default {
		data() {
			return {
				rechargeMoney: 0, //充值金额
				account: '', //用户账号
				memberInfo: {}, //会员信息
				showChargeFlag: false, //显示充值框
				recharges:[],//可用的充值套餐
			}
		},
		created() {
			this.account = this.$route.params["account"];
			this.getUserInfo();
			this.getDisCounts();
		},
		methods: {
			//充值
			chargeMoney() {

			},
			//获取所有优惠充值信息
			getDisCounts(){
				this.recharges =[];
				getDisCounts(apis.getDisCounts+"?flag=wx&account="+this.account).then(res =>{
					if(res.resultCode == constant.SUCCESS && res.data) {
						this.recharges = res.data;
					}
				})
			},
			getUserInfo() {
				getUserInfo(apis.getUserInfo, {
					"account": this.account
				}).then(res => {
					if (res.resultCode == constant.SUCCESS && res.data) {
						this.memberInfo = res.data["wxUserMember"];
					}

				})
			},
			goBack() {
				this.$router.go(-1);
			}
		}
	}
</script>

<style>
	@import "../../assets/css/returnBtn.css";
</style>
